--- title: "L1-103 整数的持续性" created: 2025-11-28 tags: - 算法 --- # L1-103 整数的持续性 ## 题目 [L1-103 整数的持续性](https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=1781658570803388422&page=1) ![[image-dd75ae62.png]] ## 思路分析 ## 代码实现 ```cpp #include using namespace std; #define endl '\n' using ll = long long; using ull = unsigned long long; using PII = pair; using Pll = pair; int dx[4]= {-1,0,1,0},dy[4]= {0,1,0,-1}; const int inf = 0x3f3f3f3f; int calc(int n) { int sum=1; while(n) { sum*=n%10; n/=10; } return sum; } int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int a,b; cin>>a>>b; int maxv=-inf; vector ans; for(int i=a; i<=b; i++) { int tmp=i; int step=0; while(tmp>=10) { tmp = calc(tmp); step++; } if(step>maxv) { maxv=step; ans.clear(); ans.push_back(i); } else if(step==maxv) { ans.push_back(i); } } cout<